// pages/login/upLoad/index.js
var app = getApp()  
Page({

  /**
   * 页面的初始数据
   */
  data: {
    progress:0,
    display1: "inline-block",
    display2: "none",
    list0: {
        src: '../../../images/iconImgs/zheng1.png',
        upload:"点此上传照片",
        text:"1.身份证",
        id:0
      },
    list1: {
        src: '../../../images/iconImgs/zheng1.png',
        upload: "点此上传照片",
        text: "2.银行卡",
        id:1
      },
    list2: {
        src: '../../../images/iconImgs/zheng1.png',
        upload: "点此上传照片",
        text: "3.健康证",
        id:2
      },
    list3:{
        src: '../../../images/iconImgs/zheng1.png',
        upload: "点此上传照片",
        text: "4.从业资格证",
        id:3
      },
  },
  upPic0:function(e){
    var that =this
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'], 
      success: function(res) {
        var tempFilePaths = res.tempFilePaths
        var list0={
            src: '../../../images/iconImgs/zheng1.png',
            upload:"点此上传照片",
            text:"1.身份证",
            id:0
          }
        list0.src = tempFilePaths[0]
        that.setData({
          list0:list0,
          display1:"none",
          display2: "inline-block",
        })
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', //仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'idCard',
          formData: {
            'pic': that.data.list0.text
          },
          success: function (res) {
            var data = res.data
            //do something
          }
        })
        const uploadTask = wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', //仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'idCard',
          formData: {
            'pic': that.data.list0.text
          },
          success: function (res) {
            var data = res.data
            //do something
          }
        })
        uploadTask.onProgressUpdate((res) => {
          that.setData({
            prprogress: res.prprogress
          })
         
        })

      }
    })
  },
  upPic1: function (e) {
    var that = this
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success: function (res) {
        var tempFilePaths = res.tempFilePaths
        var list1 = {
          src: '../../../images/iconImgs/zheng1.png',
          upload: "点此上传照片",
          text: "1.身份证",
          id: 0
        }
        list1.src = tempFilePaths[0]
        that.setData({
          list1: list1
        })
      },
    })
  },
  upPic2: function (e) {
    var that = this
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success: function (res) {
        var tempFilePaths = res.tempFilePaths
        var list2 = {
          src: '../../../images/iconImgs/zheng1.png',
          upload: "点此上传照片",
          text: "1.身份证",
          id: 0
        }
        list2.src = tempFilePaths[0]
        that.setData({
          list2: list2
        })
      },
    })
  },
  upPic3: function (e) {
    var that = this
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success: function (res) {
        var tempFilePaths = res.tempFilePaths
        var list3 = {
          src: '../../../images/iconImgs/zheng1.png',
          upload: "点此上传照片",
          text: "1.身份证",
          id: 0
        }
        list3.src = tempFilePaths[0]
        that.setData({
          list3: list3
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})